﻿using System;
using System.Collections.Generic;
using System.IO;
using ProjScan.Modules;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager
{
	// Token: 0x0200027C RID: 636
	internal class MaterialRecordManager : RecordManagerBase<MaterialAssetData>
	{
		// Token: 0x060010E3 RID: 4323 RVA: 0x0004E354 File Offset: 0x0004C554
		public override void PrepareAssets()
		{
			ScanLog.Instance.LogScanInfo(Module.Basic_Assets_Check, ScanLog.Stage.s3, "DetailedInfo(Material)", "EnterScan");
			this.datas = new List<MaterialAssetData>();
			string a = "mat";
			int num = AssetPathManager.Instance.artPathList.Length;
			for (int i = 0; i < num; i++)
			{
				bool isEditor = Singleton<ScanInfo>.Instance.isEditor;
				if (isEditor)
				{
					EditorUtility.DisplayProgressBar("Proj Scan [" + this.TableTag + "]", string.Concat(new string[]
					{
						"Preparing ",
						this.TableTag,
						"(",
						this.datas.Count.ToString(),
						")..."
					}), (float)i * 1f / (float)num);
				}
				string text = AssetPathManager.Instance.artPathList[i];
				string b = Path.GetExtension(text).ToLower().Replace(".", "");
				bool flag = string.Equals(a, b);
				if (flag)
				{
					this.ActiveAllRecord();
					bool flag2 = this.CheckAssetPathRules(text);
					if (flag2)
					{
						ScanLog.Instance.LogScanInfo(Module.Basic_Assets_Check, ScanLog.Stage.s3, "DetailedInfo(Material)", "Before LoadAssetAtPath");
						Material material = AssetDatabase.LoadAssetAtPath(text, typeof(Material)) as Material;
						ScanLog.Instance.LogScanInfo(Module.Basic_Assets_Check, ScanLog.Stage.s3, "DetailedInfo(Material)", "After LoadAssetAtPath");
						bool flag3 = material != null;
						if (flag3)
						{
							MaterialAssetData materialAssetData = new MaterialAssetData(AssetPathManager.Instance.GetID(Path.GetDirectoryName(text)), text, material);
							materialAssetData.id = this.datas.Count;
							this.ValidateAsset(materialAssetData);
							materialAssetData.Reset();
							this.datas.Add(materialAssetData);
							bool flag4 = this.datas.Count % 100 == 0;
							if (flag4)
							{
								ToolsHelper.GC();
							}
						}
					}
				}
			}
		}

		// Token: 0x1700037A RID: 890
		// (get) Token: 0x060010E4 RID: 4324 RVA: 0x0004E540 File Offset: 0x0004C740
		public override string TableTag
		{
			get
			{
				return "material";
			}
		}
	}
}
